package com.qf.controller.dingdan_controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.bean.Order;
import com.qf.service.dingdan_service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class OrderController {
    @Autowired
    OrderService service;

    @RequestMapping("/xiangxi")
    public String gets(Model model,Integer oid){
        List<Order> list = service.findAll(oid);
        model.addAttribute("lists",list);
        for (Order order : list) {
            System.out.println(order.toString());
        }
        return "/order/ordershow";
    }



    @RequestMapping("/getorders")
    public String test(Integer pageNum,Model model,Integer oid){
        if (pageNum==null || pageNum==0){
            pageNum=1;
        }
        PageHelper.startPage(pageNum, 3);
        List<Order> orders = service.findAll(oid);
        PageInfo<Order> orderPageInfo = new PageInfo<>(orders);
        model.addAttribute("page",orderPageInfo);
        model.addAttribute("orders",orders);
        return "/order/orderlist";
    }

}
